﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->
    
<UserControl x:Class="System.Windows.Controls.Samples.DataFormHeterogeneousDataSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dataform="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
    xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <StackPanel>
        <ContentControl Content="DataForm with Heterogeneous Data" Style="{StaticResource Header}" />
        <StackPanel>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0">
                    <CheckBox Content="AutoCommit" IsChecked="{Binding AutoCommit, ElementName=dataForm, Mode=TwoWay}" Margin="4" />
                    <CheckBox Content="AutoEdit" IsChecked="{Binding AutoEdit, ElementName=dataForm, Mode=TwoWay}" Margin="4" />
                    <TextBlock Text="CommandButtonsVisibility" Style="{StaticResource ApiName}" Margin="4" />
                    <ComboBox SelectedItem="{Binding CommandButtonsVisibility, ElementName=dataForm, Mode=TwoWay}" SelectedIndex="0" Margin="4">
                        <sys:String>All</sys:String>
                        <sys:String>Add</sys:String>
                        <sys:String>Delete</sys:String>
                        <sys:String>Edit</sys:String>
                        <sys:String>Navigation</sys:String>
                        <sys:String>None</sys:String>
                    </ComboBox>
                    <CheckBox Content="IsReadOnly" IsChecked="{Binding IsReadOnly, ElementName=dataForm, Mode=TwoWay}" Margin="4" />
                </StackPanel>
                <dataform:DataForm x:Name="dataForm" Width="350" ItemsSource="{Binding}" HorizontalAlignment="Left" MaxWidth="500" Margin="4" Grid.Column="1" />
            </Grid>
        </StackPanel>
        <src:SourceViewer xmlns:src="clr-namespace:System.Windows.Controls.Samples;assembly=System.Windows.Controls.Samples.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <src:SourceFile Path="DataFormHeterogeneousDataSample.xaml">
    <src:SourceFile.Source>
      <sys:String>&lt;!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
--&gt;
    
&lt;UserControl x:Class="System.Windows.Controls.Samples.DataFormHeterogeneousDataSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dataform="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
    xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"&gt;
    &lt;StackPanel&gt;
        &lt;ContentControl Content="DataForm with Heterogeneous Data" Style="{StaticResource Header}" /&gt;
        &lt;StackPanel&gt;
            &lt;Grid&gt;
                &lt;Grid.ColumnDefinitions&gt;
                    &lt;ColumnDefinition Width="Auto" /&gt;
                    &lt;ColumnDefinition /&gt;
                &lt;/Grid.ColumnDefinitions&gt;
                &lt;StackPanel Grid.Column="0"&gt;
                    &lt;CheckBox Content="AutoCommit" IsChecked="{Binding AutoCommit, ElementName=dataForm, Mode=TwoWay}" Margin="4" /&gt;
                    &lt;CheckBox Content="AutoEdit" IsChecked="{Binding AutoEdit, ElementName=dataForm, Mode=TwoWay}" Margin="4" /&gt;
                    &lt;TextBlock Text="CommandButtonsVisibility" Style="{StaticResource ApiName}" Margin="4" /&gt;
                    &lt;ComboBox SelectedItem="{Binding CommandButtonsVisibility, ElementName=dataForm, Mode=TwoWay}" SelectedIndex="0" Margin="4"&gt;
                        &lt;sys:String&gt;All&lt;/sys:String&gt;
                        &lt;sys:String&gt;Add&lt;/sys:String&gt;
                        &lt;sys:String&gt;Delete&lt;/sys:String&gt;
                        &lt;sys:String&gt;Edit&lt;/sys:String&gt;
                        &lt;sys:String&gt;Navigation&lt;/sys:String&gt;
                        &lt;sys:String&gt;None&lt;/sys:String&gt;
                    &lt;/ComboBox&gt;
                    &lt;CheckBox Content="IsReadOnly" IsChecked="{Binding IsReadOnly, ElementName=dataForm, Mode=TwoWay}" Margin="4" /&gt;
                &lt;/StackPanel&gt;
                &lt;dataform:DataForm x:Name="dataForm" Width="350" ItemsSource="{Binding}" HorizontalAlignment="Left" MaxWidth="500" Margin="4" Grid.Column="1" /&gt;
            &lt;/Grid&gt;
        &lt;/StackPanel&gt;
    &lt;/StackPanel&gt;
&lt;/UserControl&gt;</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="DataFormHeterogeneousDataSample.xaml.cs">
    <src:SourceFile.Source>
      <sys:String>// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Data;

namespace System.Windows.Controls.Samples
{
    /// &lt;summary&gt;
    /// Sample page demonstrating the DataForm control with heterogeneous data.
    /// &lt;/summary&gt;
    [Sample("DataForm with heterogeneous data", DifficultyLevel.Intermediate)]
    [Category("DataForm")]
    public partial class DataFormHeterogeneousDataSample : UserControl
    {
        /// &lt;summary&gt;
        /// Initializes a DataFormHeterogeneousDataSample.
        /// &lt;/summary&gt;
        public DataFormHeterogeneousDataSample()
        {
            InitializeComponent();
            ObservableCollection&lt;object&gt; objects = new ObservableCollection&lt;object&gt;();
            foreach (object obj in Contact.People)
            {
                objects.Add(obj);
            }
            Random r = new Random();
            foreach (object obj in Airport.SampleAirports)
            {
                objects.Insert(r.Next(objects.Count), obj);
            }
            DataContext = new ReadOnlyObservableCollection&lt;object&gt;(objects);
        }
    }
}
</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="DataFormHeterogeneousDataSample.xaml.vb">
    <src:SourceFile.Source>
      <sys:String>' (c) Copyright Microsoft Corporation.
' This source is subject to the Microsoft Public License (Ms-PL).
' Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
' All other rights reserved.

Imports System.Collections.ObjectModel
Imports System.ComponentModel

''' &lt;summary&gt;
''' Sample page demonstrating the DataForm control with heterogeneous data.
''' &lt;/summary&gt;
&lt;Sample("DataForm with heterogeneous data", DifficultyLevel.Intermediate)&gt; _
&lt;Category("DataForm")&gt; _
Partial Public Class DataFormHeterogeneousDataSample
    Inherits UserControl

    ''' &lt;summary&gt;
    ''' Initializes a DataFormHeterogeneousDataSample.
    ''' &lt;/summary&gt;
    &lt;System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification:="InitializeComponent Required by Visual Studio.")&gt; _
    Public Sub New()
        InitializeComponent()
        Dim objects As ObservableCollection(Of Object) = New ObservableCollection(Of Object)
        For Each obj In Contact.People
            objects.Add(obj)
        Next
        Dim r As Random = New Random()
        For Each obj In Airport.SampleAirports
            objects.Insert(r.Next(objects.Count), obj)
        Next
        DataContext = objects
    End Sub
End Class</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
</src:SourceViewer>
    </StackPanel>
</UserControl>